package top.suven.base.core.mq.rocketmq;

import top.suven.base.util.utilize.JsonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @ClassName:
 * @Description:
 * @Author lixiangling
 * @Date 2018/6/27 15:53
 * @Copyright: (c) 2018 gc by https://www.gc.com.cn/
 * @Version : 1.0.0
 * --------------------------------------------------------
 * modifyer    modifyTime                 comment
 * <p>
 * --------------------------------------------------------
 */
public class RocketMQFailExecThread implements Runnable {
    private Logger logger = LoggerFactory.getLogger(RocketMQFailExecThread.class);
    private RocketMQConsumerMsgFail msgFail;
    private RocketMQFailHandler rocketMQFailHandler;

    public RocketMQFailExecThread(RocketMQConsumerMsgFail msgFail, RocketMQFailHandler rocketMQFailHandler){
        this.msgFail = msgFail;
        this.rocketMQFailHandler = rocketMQFailHandler;
    }
    @Override
    public void run() {
        try {
            rocketMQFailHandler.handleFailInfo(msgFail);
        }catch (Exception e) {
            logger.error(String.format("consumer rocketMq message record error topic=%s,msg=%s", msgFail.getTopicName(), JsonUtils.toJsonString(msgFail.getRocketMQMessage())),e);
        }
    }
}
